package com.talking.adapter;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.talking.R;
import com.talking.bean.UserBean;
import com.talking.databinding.ItemGroupMemberBinding;
import com.talking.model.Http;
import com.talking.utils.Utils;

import java.util.List;

public class GroupMemberAdapter extends ArrayAdapter<UserBean> {
    private static final int layoutId = R.layout.item_group_member;
    private final Activity context;
    public GroupMemberAdapter(Activity context, List<UserBean> objects){
        super(context,layoutId,objects);
        this.context=context;
    }
    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        UserBean userBean = getItem(position);
        @SuppressLint("ViewHolder") @NonNull ItemGroupMemberBinding binding = ItemGroupMemberBinding.inflate(LayoutInflater.from(context));
        Glide.with(context).load(Http.BASE_URL+userBean.iconUrl).apply(Utils.getGlideOption()).placeholder(R.drawable.loading).placeholder(R.drawable.loading).error(R.drawable.loaderr).into(binding.itemGroupMemberIv);
        return binding.getRoot();
    }
}